package com.pb.wkflow.api.controller;

import com.pb.infra.oth.entity.common.Result;
import com.pb.wkflow.api.controller.request.TaskHandOverCreateRequest;
import com.pb.wkflow.api.controller.request.TaskHandOverQueryRequest;
import com.pb.wkflow.api.service.TaskHandOverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 任务移交配置
 * @author 苗益辉
 * @date 2022/12/26 15:00
 */
@RestController
@RequestMapping("v1/workflow/taskHandOver")
public class TaskHandOverApi {

    /**
     * TaskHandOverService
     */
    @Autowired
    TaskHandOverService taskHandOverService;

    /**
     * 分页查询
     * @param pageIndex 页码
     * @param pageSize 页数
     * @param request request
     * @return Result
     */
    @PostMapping("_searchByPage")
    public Result searchByPage(@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
                               @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
                               @RequestBody TaskHandOverQueryRequest request)  {
        return taskHandOverService.searchByPage(pageIndex, pageSize, request);
    }

    /**
     * 新增
     * @param request request
     * @return Result
     */
    @PostMapping("_insert")
    public Result insert(@RequestBody TaskHandOverCreateRequest request) {
        taskHandOverService.insert(request);
        return Result.ok("新增成功");
    }

    /**
     * 修改
     * @param request request
     * @return Result
     */
    @PostMapping("_edit")
    public Result edit(@RequestBody TaskHandOverCreateRequest request) {
        taskHandOverService.edit(request);
        return Result.ok("修改成功");
    }

    /**
     * 删除
     * @param request request
     * @return Result
     */
    @PostMapping("_delete")
    public Result delete(@RequestBody TaskHandOverCreateRequest request) {
        taskHandOverService.delete(request);
        return Result.ok("删除成功");
    }
}
